package com.yonyou.crm.cum.customer.ctrl;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.yonyou.crm.common.base.EnterpriseBaseCtrl;
import com.yonyou.crm.common.exception.CrmMessageException;
import com.yonyou.crm.common.rest.util.ResponseUtil;

@RestController
@RequestMapping(value = "/cum/customers")
public class EnterpriseCtrl extends EnterpriseBaseCtrl {

	/**
	 * 企业信息按名称查询
	 * 
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "identifications", method = RequestMethod.GET)
	public Object getEnteInfoByName(HttpServletRequest request,
			HttpServletResponse response) throws CrmMessageException {
		Object data = super.getEnteInfoByName(request);
		Map<String, Object> res = new HashMap<>();
		res.put("data", data);
		return ResponseUtil.getObject(res);
	}

	/**
	 * 企业信息精确查询
	 * 
	 * @param request
	 * @param response
	 * @throws CrmMessageException
	 */
	@RequestMapping(value = "identifications/{id}", method = RequestMethod.GET)
	public Object getEnteInfoByCompanyId(@PathVariable("id") String id,
			HttpServletRequest request, HttpServletResponse response)
			throws CrmMessageException {
		Object list = super.getEnteInfoByCompanyId(id);
		Map<String, Object> res = new HashMap<>();
		res.put("data", list);
		return ResponseUtil.getObject(res);
	}

	/**
	 * 企业信息全词查询
	 * 
	 * @param request
	 * @param response
	 * @throws CrmMessageException
	 */
	@RequestMapping(value = "identifications/full", method = RequestMethod.GET)
	public Object getEnteInfoByFullName(HttpServletRequest request,
			HttpServletResponse response) throws CrmMessageException {
		Object list = super.getEnteInfoByFullName(request);
		Map<String, Object> res = new HashMap<>();
		res.put("data", list);
		return ResponseUtil.getObject(res);
	}

	/**
	 * 审核、取消审核
	 * 
	 * @param id
	 * @param request
	 * @param response
	 * @throws CrmMessageException
	 */
	@RequestMapping(value = "{id}/identifications", method = RequestMethod.PUT)
	public Object identification(@PathVariable("id") String id,
			HttpServletRequest request, HttpServletResponse response)
			throws CrmMessageException {
		return super.identification(id, request);
	}

	/**
	 * 根据客户id获取审核信息
	 * 
	 * @param id
	 * @param request
	 * @param response
	 * @throws CrmMessageException
	 */
	@RequestMapping(value = "{id}/identifications", method = RequestMethod.GET)
	public Object getEnteInfoByCustomerId(@PathVariable("id") String id,
			HttpServletRequest request, HttpServletResponse response)
			throws CrmMessageException {
		Map<String, Object> res = super.getEnteInfoByCustomerId(id, request);
		return ResponseUtil.getObject(res);
	}

}
